package com.xmy.cultivate.mapper;

import com.xmy.cultivate.entity.RecordCourseLack;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;

/**
 * <p>
 * 记上课先扣课时，金额保存 Mapper 接口
 * </p>
 *
 * @author hpiggy
 * @since 2024-06-04
 */
public interface RecordCourseLackMapper extends BaseMapper<RecordCourseLack> {

    @Select("SELECT IFNULL( SUM( a.buckle_class_money ), 0 ) AS buckle_class_money FROM record_course_lack as a LEFT JOIN record_course as b on a.id = b.id WHERE a.order_detail_id = ${orderDetailId} AND a.deleted = 0 AND a.is_deduct_money = 0 and b.is_repair <>1 and b.`status` <>1 and b.is_deduct_money = 0")
    public BigDecimal getAllBucklemoneyForOrderDetailId(@Param("orderDetailId") Long orderDetailId);
}
